// Collector API
//
// Paul E.C. Melis (paul@floorball-flamingos.nl), March 31st, 2010

#ifndef ALLOC_H
#define ALLOC_H

struct gc_object;

typedef void (*gc_visitor) (struct gc_object*);

struct gc_object {    
  struct gc_object* next;
  unsigned char marked;
  gc_visitor visitor;
  unsigned int size;
};

struct gc_global_object {
  struct gc_global_object* next;
  struct gc_object** addr;
};

struct gc_queue_object {
  struct gc_object* object;
  struct gc_queue_object* next;
};

// Garbage collector routines
void    gc_init() __attribute__ ((constructor));
void    gc_heap(unsigned int sz);
void    gc_info(void);
void*   gc_alloc(unsigned int sz, gc_visitor visitor );
void    gc_add_root(struct gc_object**);
void    gc_collect();
void    gc_shutdown() __attribute__ ((destructor));
void    gc_visit(struct gc_object* object);
#endif
